﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="baseinfo.aspx.cs" Inherits="MxWeiXinPF.Web.weixin.jiaoshuifei.baseinfo" %>

<%decimal totalOweAmt = 0;%>
<%if (model != null && !string.IsNullOrEmpty(model.totalOweAmt))
    {
        totalOweAmt = Convert.ToDecimal(model.totalOweAmt) / 100;
    } %>
<!DOCTYPE html>

<html>
<head runat="server">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <link href="css/weui.min.css?v=2" rel="stylesheet" />
    <link href="css/jquery-weui.min.css" rel="stylesheet" />
    <link href="css/demos.css" rel="stylesheet" />
    <title>在线缴费</title>
</head>
<body ontouchstart>

    <%if (model != null)
        {
    %>
    <div class="weui-form-preview">
        <div class="weui-form-preview__bd">
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">用户号</label>
                <span class="weui-form-preview__value"><%=model.consno%></span>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">用户名</label>
                <span class="weui-form-preview__value"><%=model.consname%></span>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">地址</label>
                <span class="weui-form-preview__value"><%=model.addr%></span>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">应缴金额</label>
                <span class="weui-form-preview__value"><%=Convert.ToDecimal(model.totalRcvblAmt)/100%>元</span>
                <%if (Convert.ToDecimal(model.totalRcvblAmt) / 100 > 0)
                    {%>
                <div class="button_sp_area">
                    <a href="paymentdetail.aspx?wid=<%=wid %>&consno=<%= model.consno%>&consname=<%=model.consname %>" class="weui-btn weui-btn_mini weui-btn_primary">明细</a>
                </div>
                <%  }
                else
                {%>
                <div class="button_sp_area">
                    <a href="javascript:void(0);" class="weui-btn weui-btn_mini weui-btn_disabled weui-btn_default">明细</a>
                    <% } %>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">余额</label>
                    <span class="weui-form-preview__value"><%=Convert.ToDecimal(model.prepayamt)/100%>元</span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">欠费金额</label>
                    <span class="weui-form-preview__value"><%=totalOweAmt%>元</span>
                    <input type="hidden" id="totalOweAmt" value="<%=totalOweAmt%>" />
                </div>
            </div>

              </div>
        </div>

            <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_vcode">
                    <div class="weui-cell__hd">
                        <label class="weui-label">缴费金额</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" id="amount" style="font-size: 24px; font-weight: bold"   value="<%=totalOweAmt!=0?totalOweAmt.ToString():""%>"  placeholder="请输入缴费金额"  />
                    </div>
                    <div class="weui-cell__ft">
                        <button class="weui-vcode-btn">元</button>
                    </div>
                </div>
            </div>

            <div class='demos-content-padded'>
                <a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips" onclick="next()">下一步</a>
            </div>


      
        <%} %>
        <script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
        <script src="js/jquery-weui.js"></script>
        <script>
            //下一步(创建订单=>成功跳转到支付界面)
            function next() {

                var amount = $("#amount").val();
                var reg = /^\d*\.?\d{1,2}$/;
                if (!reg.test(amount)) {
                    $.toptip('请输入正确的金额');
                    return;
                }
                var totalOweAmt = $("#totalOweAmt").val();
                if (parseFloat(amount) < parseFloat(totalOweAmt)) {
                    $.toptip('缴费金额不能小于欠费金额');
                    return;
                }
                if (parseFloat(amount) == 0) {
                    $.toptip('请输入正确的金额');
                    return;
                }
                $.ajax({
                    type: "post",
                    url: "jsf_bindOne.ashx",
                    data: { usernumber: '<%=model.consno%>', username: '<%=model.consname%>', actionType: "SaveOrder", wid: '<%=wid%>', amount: amount, openid: '<%=openid%>' },
                    beforeSend: function () {
                        $.showLoading();

                    },
                    success: function (data) {
                        if (data.succuss == 1) {
                            window.location.href = "/api/payment/paypage.aspx?showwxpaytitle=1&paytype=jiaoshuifei&wid=<%=wid%>&orderid=" + data.order_no;
                    }
                    else {
                        $.hideLoading();
                        $.toptip(data.msg);

                    }
                }
                });
        }
        </script>
</body>
</html>
